package com.jwthhealth_pub.old.acupressure.view;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;


import com.jwthhealth_pub.R;
import com.jwthhealth_pub.common.view.TitleLayout;
import com.jwthhealth_pub.old.acupressure.module.AcupressureAcupointModule;
import com.jwthhealth_pub.old.api.ApiHelper;
import com.jwthhealth_pub.old.common.Constant;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/1/13.
 */
public class SeasonAndSickInfoActivity extends Activity {
    @BindView(R.id.webview)
    WebView webview;
    @BindView(R.id.sign_topbar)
    TitleLayout signTopbar;
    private AcupressureAcupointModule.DataBean data;
    private String type;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_season_and_sick_info);
        ButterKnife.bind(this);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }

        data = (AcupressureAcupointModule.DataBean) getIntent().getExtras().getSerializable(Constant.ACUPRESSUREDATA);
        type = (String) getIntent().getExtras().getSerializable(Constant.ACUPRESSURETYPE);
        initTop();

        String url = ApiHelper.acupressureNewsdetail(data.getId());

        webview.loadUrl(url);
        webview.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return super.shouldOverrideUrlLoading(view, url);
            }
        });

    }

    private void initTop() {
        if (type.equals("2")) {
            signTopbar.setTitle(getString(R.string.acupressure_title_season));
        } else if (type.equals("1")) {
            signTopbar.setTitle(getString(R.string.acupressure_title_sick));
        }

        signTopbar.setOnTitleLayoutListener(new TitleLayout.TitleLayoutListener() {
            @Override
            public void leftclick() {
                finish();
            }

            @Override
            public void leftTextClick() {

            }

            @Override
            public void rightclick() {

            }

            @Override
            public void rightTextClick() {

            }
        });
    }
}
